package com.explorex.infra.puma.gateway.netty.common.enums;

import com.google.common.collect.HashBasedTable;

import java.util.Arrays;
import java.util.Optional;

public enum EnumTerminal {
    MOBILE(0, "mobile"),
    PAD(1, "pad"),
    WEB(2, "web"),
    WINDOWS(3, "windows"),
    MAC(4, "mac"),
    ALL(101, "all");

    private final int value;
    private final String name;

    public static Optional<EnumTerminal> findByValue(int value) {
        return Arrays.stream(values()).filter((e) -> {
            return e.value == value;
        }).findFirst();
    }

    public static EnumTerminal getEnumTerminal(Integer value) {
        if (value == null) {
            return MOBILE;
        } else {
            switch(value) {
            case 1:
                return PAD;
            case 2:
                return WEB;
            case 3:
                return WINDOWS;
            case 4:
                return MAC;
            case 101:
                return ALL;
            default:
                return MOBILE;
            }
        }
    }


    private EnumTerminal(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return this.value;
    }

}